<template>
  <view class="container" :style="{ paddingTop: safeAreaInsets.top + 'px' }">
    <view class="title">法言</view>
    <!-- 搜索栏 -->
    <view class="search-bar">
      <input type="text" placeholder="请输入信息搜索" class="fontSize"/>
    </view>

    <!-- 横幅 -->
    <view class="banner">
      <swiper :circular="true" :autoplay="true" :interval="3000">
      <swiper-item>
        <navigator url="/pages/index/index" hover-class="none" class="navigator">
          <image
            mode="aspectFill"
            class="image"
            src="https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/uploads/slider_1.jpg"
          ></image>
        </navigator>
      </swiper-item>
      <swiper-item>
        <navigator url="/pages/index/index" hover-class="none" class="navigator">
          <image
            mode="aspectFill"
            class="image"
            src="https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/uploads/slider_2.jpg"
          ></image>
        </navigator>
      </swiper-item>
      <swiper-item>
        <navigator url="/pages/index/index" hover-class="none" class="navigator">
          <image
            mode="aspectFill"
            class="image"
            src="https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/uploads/slider_3.jpg"
          ></image>
        </navigator>
      </swiper-item>
    </swiper>
    </view>

    <!-- 功能按钮 -->
    <view class="function-buttons">
      <view class="button" @click="goToLegalLecture">法律大讲堂</view>
      <view class="button" @click="goToContractLibrary">合同文库</view>
    </view>

    <!-- 热点专栏 -->
    <view class="hot-topics">
      <view class="tltie-header">
        <view class="section-title">
          <image
            src="/src/static/mine10/组 142@2x.png"
            mode="scaleToFill"
            class="section-image"
          />
          <view>热点专栏</view>
        </view>
        <view class="more" @click="goToMoreHotTopics">
          <view class="text-more">更多</view>
          <image src="/src/static/mine10/right-icon.png" class="image"></image>
        </view>
      </view>

      <view class="topic-list">
        <view class="topic-item" v-for="topic in hotTopics" :key="topic.title">
          <view class="topic-title">
            <image
              src="/src/static/mine10/容器 2@2x.png"
              mode="scaleToFill"
              class="topic-image"
            />
            <view>{{ topic.title }}</view>
          </view>
          <text class="topic-date">{{ topic.date }}</text>
        </view>
      </view>
    </view>

    <!-- 专家论法 -->
    <view class="hot-topics expert-law">
      <view class="tltie-header">
        <view class="section-title">
          <image
            src="/src/static/mine10/组 142@2x (1).png"
            mode="scaleToFill"
            class="section-image"
          />
          <view>专家论法</view>
        </view>
        <view class="more" @click="goToMoreExpertOpinions">
          <view class="text-more">更多</view>
          <image src="/src/static/mine10/right-icon.png" class="image"></image>
        </view>
      </view>
      <view class="topic-list">
        <view class="export-item" v-for="topic in expertOpinion" :key="topic.title">
          <text class="topic-title export-title">{{ topic.title }}</text>
          <text class="topic-date">{{ topic.abstract }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()
// 热点专栏数据
const hotTopics = ref([
  {
    title: 'RCEP国家外商投资并购指南、跨境...',
    date: '2025-02-24'
  },
  {
    title: '中东北非外贸投资指南',
    date: '2025-02-24'
  },
  {
    title: '"走出去"知识产权保护及实操',
    date: '2025-02-24'
  },
  {
    title: '新能源电动汽车出海',
    date: '2025-02-24'
  },
  {
    title: 'RCEP国家外商投资并购...',
    date: '2025-02-24'
  }
]);

// 专家论法数据
const expertOpinion = ref(
  [
    {
      title: '政府政策变化，何以构成不可抗力｜陈·述',
      abstract: '不可抗力裁量空间的填补有赖于对已有判例裁判规则的梳理和总结。'
    },
    {
      title: '政府政策变化，何以构成不可抗力｜陈·述',
      abstract: '不可抗力裁量空间的填补有赖于对已有判例裁判规则的梳理和总结。'
    },
    {
      title: '政府政策变化，何以构成不可抗力｜陈·述',
      abstract: '不可抗力裁量空间的填补有赖于对已有判例裁判规则的梳理和总结。'
    }
  ]
);

// 导航方法
const goToLegalLecture = () => {
  // 跳转到法律大讲堂页面
  uni.navigateTo({
    url: '/pages/index/lawClass'
  });
};

const goToContractLibrary = () => {
  // 跳转到合同文库页面
  uni.navigateTo({
    url: '/pages/contractLibrary'
  });
};

const goToMoreHotTopics = () => {
  // 跳转到更多热点专栏页面
  uni.navigateTo({
    url: '/pages/moreHotTopics'
  });
};

const goToMoreExpertOpinions = () => {
  // 跳转到更多专家论法页面
  uni.navigateTo({
    url: '/pages/moreExpertOpinions'
  });
};
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(#E2EAFF, rgba(255, 255, 255, 0));
}

.title {
  margin-top: 10rpx;
}

.fontSize{
  font-size: 26rpx;
  color: #AEB6C2;
}
.search-bar {
  width: 90%;
  margin-top: 40rpx;
  padding: 20rpx;
  background-color: #fff;
  border-radius: 10rpx;
}

.banner {
  width: 90%;
  position: relative;
  margin-top: 40rpx;
}

.banner image {
  width: 100%;
  height: 400rpx;
}

.banner-text {
  position: absolute;
  bottom: 40rpx;
  left: 40rpx;
  color: white;
}

.banner-title {
  font-size: 40rpx;
  font-weight: bold;
}

.banner-subtitle {
  font-size: 14px;
}

.function-buttons {
  width: 90%;
  display: flex;
  justify-content: space-between;
  margin-top: 40rpx;
}

.button {
  width: 48%;
  height: 50px;
  line-height: 50px;
  text-align: center;
  background-color: #007AFF;
  color: white;
  border-radius: 10px;
}

.hot-topics {
  width: 90%;
  margin-top: 40rpx;
  background-color: rgb(124, 163, 255);
  padding: 10rpx;
  border-radius: 12rpx;
}

.section-title {
  font-size: 18px;
  font-weight: bold;
  margin-left: 20rpx;
  display: flex;

}

.section-image{
  width: 40rpx;
  height: 40rpx;
  margin-right: 20rpx;
}

.more {
  margin-right: 20rpx;
  display: flex;
}

.image {
  width: 40rpx;
  height: 40rpx;
  margin-top: 5rpx;
}

.tltie-header{
  display: flex;
  justify-content: space-between;
  padding: 20rpx 0;
  color: #fff;
}

.topic-list {
  background-color: #fff;
  border-radius: 24rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.topic-item {
  margin-top: 10px;
  padding: 10px;
  border-bottom: 1px solid #ccc;
  display: flex;
  justify-content: space-between;
  width: 88%;
  text-align: center;
}

.export-item {
  margin-top: 10px;
  padding: 10px;
  border-bottom: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  width: 88%;
}

.topic-title {
  font-size: 24rpx;
  color: #646464;
  display: flex;
}

.topic-image{
  margin:3rpx  20rpx 0 0;
  width: 30rpx;
  height: 30rpx;
}

.topic-date {
  font-size: 12px;
  color: #999;
}

.expert-opinion {
  width: 90%;
  margin-top: 40rpx;
  border: 1px solid #000;
}

.opinion-item {
  margin-top: 10px;
  padding: 10px;
  border-bottom: 1px solid #ccc;
}

.opinion-title {
  font-size: 16px;
}

.opinion-abstract {
  font-size: 12px;
  color: #999;
}
.export-title{
  margin-bottom: 10rpx;
}
.expert-law{
  background-color: rgb(116, 189, 150);
}
</style>